//
// Created by 15760 on 2022/11/7.
//

#ifndef CPP_PROJECT_PLAYER_H
#define CPP_PROJECT_PLAYER_H

#include "card.h"
#include "coin.h"
#include <vector>
#include "piles.h"


class Player {
private:
    vector<Card*> cards; //起始每名玩家有两张起始牌
    unsigned int no;   //玩家编号，与起始玩家数量有关 0,1,2,3
    Coin coin;
public:
    Player(unsigned int n);
    const unsigned int getNo() const {return no;}
    void addACard(const Card& card);
    void exchangeACard(const vector<Card*>::iterator pos, const Card& card);
    const bool haveTrainStation() const;
    Coin& getCoin() {return coin;}
    const vector<Card*>& getCards() const {return cards;}
    const bool haveSameTypeCard(const Card& card) const;
    //adapter of class
    class iterator : public vector<Card*>::iterator {
    public:
        iterator(typename vector<Card*>::iterator it):
                vector<Card*>::iterator(it) {}
    };
    iterator begin() {return iterator(cards.begin());}
    iterator end() {return iterator(cards.end());}
};

inline bool operator==(const Player& p1, const Player& p2) {
    return p1.getNo()==p2.getNo();
}

#endif //CPP_PROJECT_PLAYER_H
